package 刷题.leedcode36;
//链表的回文结构
public class PalindromeList1 {
    public boolean chkPalindrome(ListNode A) {
        if(A == null || A.next ==null){
            return true;
        }
        //新建一个链表，让这个链表是原来链表的逆置
        ListNode cur = null;
        ListNode prev = A;
        //反转链表
        while (prev != null){
            ListNode next = prev.next;
            prev.next = cur;
            cur = prev;
            prev = next;
        }
        while(A.next != null){
            if(A.val != cur.val){
                return false;
            }
            A = A.next;
            cur = cur.next;
        }
        return true;
    }
}